<?php
/**
 * Created by swagger_zxd.
 * User: zxd
 * Date: 2017/11/24
 * Time: 10:07
 */

namespace App\Models\Test;


use Illuminate\Database\Eloquent\Model;

class User extends Model
{

    protected $table='user';


    /**
     * 获取关联到用户的手机
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     */
    protected function phone()
    {
        //通过外键关联 参数1 关联的类，参数2 外键id ，参数1 主键id
        return $this->hasOne(Phone::class,'user_id','id');
    }

    /**
     * 获取用户的所有付款记录
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
     */
    public function hasManyPays()
    {
        return $this->hasMany(Pay::class,'user_id','id');
    }

}